<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>酒店详情</title>
    <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body {
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            color: #333;
            margin: 0;
        }
        .header {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
            padding: 20px 0;
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            z-index: 1000;
        }
        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .header-title {
            font-size: 24px;
            font-weight: 600;
            color: #333;
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .header-title::before {
            content: "🏨";
            font-size: 28px;
        }
        .back-home-btn {
            display: inline-block;
            margin: 32px auto 0 48px;
            background: #f5f5f5;
            color: #5a3ec8;
            border: none;
            border-radius: 18px;
            padding: 8px 28px;
            font-size: 16px;
            font-weight: 500;
            text-decoration: none;
            cursor: pointer;
            transition: background 0.2s, color 0.2s;
            box-shadow: 0 2px 8px #e0d7f7;
        }
        .back-home-btn:hover {
            background: #e0e7ff;
            color: #333;
        }
        .main-title {
            text-align: center;
            font-size: 40px;
            font-weight: 900;
            color: #5a3ec8;
            margin: 48px 0 32px 0;
            letter-spacing: 3px;
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
        }
        .hotel-info-container {
            display: flex;
            align-items: center;
            background: #fff;
            border-radius: 22px;
            box-shadow: 0 6px 32px #b3a6e6;
            max-width: 1100px;
            margin: 0 auto 48px auto;
            padding: 40px 48px;
            gap: 48px;
        }
        .carousel-container {
            flex: 1.2;
            min-width: 380px;
            max-width: 520px;
            aspect-ratio: 16/7;
            overflow: hidden;
            border-radius: 22px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.12);
            margin: 0;
        }
        .hotel-info-content {
            flex: 1;
            min-width: 260px;
        }
        .hotel-name {
            font-size: 32px;
            font-weight: 800;
            color: #5a3ec8;
            margin-bottom: 16px;
            letter-spacing: 1px;
        }
        .hotel-desc {
            color: #555;
            font-size: 20px;
            line-height: 1.8;
            font-weight: 400;
        }
        .section-container {
            max-width: 1100px;
            margin: 48px auto 0 auto;
            background: #fff;
            border-radius: 22px;
            box-shadow: 0 6px 32px #b3a6e6;
            padding: 40px 48px 48px 48px;
        }
        .section-title {
            font-size: 28px;
            font-weight: 800;
            color: #5a3ec8;
            margin-bottom: 32px;
            letter-spacing: 1.5px;
        }
        .room-type-list {
            display: flex;
            flex-wrap: wrap;
            gap: 40px 4%;
            justify-content: flex-start;
            align-items: stretch;
        }
        .room-type-card {
            width: 48%;
            min-width: 380px;
            max-width: 520px;
            min-height: 280px;
            background: #faf8ff;
            border-radius: 18px;
            box-shadow: 0 4px 18px #e0d7f7;
            display: flex;
            flex-direction: row;
            align-items: stretch;
            position: relative;
            overflow: hidden;
            transition: box-shadow 0.2s, transform 0.2s;
            cursor: pointer;
            margin-bottom: 0;
        }
        .room-type-card:hover {
            box-shadow: 0 12px 36px #a18cd1;
            transform: translateY(-6px) scale(1.03);
        }
        .room-type-card img {
            width: 200px;
            height: 160px;
            object-fit: cover;
            border-radius: 0 0 0 0;
            margin: 0;
            flex-shrink: 0;
        }
        .room-type-info {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 36px 32px 80px 28px; /* 底部内边距加大到80px */
            min-width: 0;
            position: relative;
        }
        .room-type-title {
            font-size: 26px;
            font-weight: 800;
            color: #5a3ec8;
            margin-bottom: 8px;
            letter-spacing: 1px;
        }
        .room-type-desc {
            color: #888;
            font-size: 18px;
            margin-bottom: 10px;
            font-family: 'Microsoft YaHei', Arial, sans-serif;
        }
        .room-type-info .info-line {
            font-size: 18px;
            color: #555;
            margin-bottom: 6px;
        }
        .room-type-divider {
            border: none;
            border-top: 1px solid #eee;
            margin: 8px 0 10px 0;
        }
        .room-type-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-top: 6px;
        }
        .room-type-price {
            color: #f5576c;
            font-size: 26px;
            font-weight: bold;
            font-family: 'Segoe UI', 'Microsoft YaHei', Arial, sans-serif;
        }
        .room-type-book {
            position: absolute;
            right: 24px;
            bottom: 24px;
            background: #5a3ec8;
            color: #fff;
            border: none;
            border-radius: 22px;
            padding: 10px 28px;
            font-size: 17px;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
            box-shadow: 0 2px 8px #e0d7f7;
            letter-spacing: 1px;
        }
        .room-type-book:hover {
            background: #764ba2;
        }
        /* 让房型卡片区域和轮播大图宽度、居中方式完全一致 */
        .main-content,
        .room-type-list,
        .carousel-container {
            width: 100vw;
            max-width: 1200px;
            margin-left: auto;
            margin-right: auto;
        }

        /* 房型卡片两列并排且更大气 */
        .room-type-list {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            align-items: stretch;
            gap: 36px 0; /* 上下间距36px，左右无gap，靠width撑开 */
            width: 100%;
            box-sizing: border-box;
        }

        .room-type-card {
            width: 48%;
            min-width: 380px;
            max-width: 580px;
            margin-bottom: 36px;
        }

        /* 移除媒体查询下的单列逻辑，强制两列 */
        @media (max-width: 1200px) {
            .main-content,
            .room-type-list,
            .carousel-container {
                max-width: 100vw;
            }
            .room-type-card {
                width: 48%;
                min-width: 200px;
                max-width: 98vw;
                margin-bottom: 24px;
            }
            .main-title, .section-container, .hotel-info-container {
                max-width: 98vw;
                padding-left: 10px;
                padding-right: 10px;
            }
            .carousel-container { width: 98vw; max-width: 98vw; }
        }
        @media (max-width: 800px) {
            .room-type-card {
                width: 48%;
                min-width: 140px;
            }
            .hotel-info-container, .section-container {
                flex-direction: column;
                padding: 18px 4vw;
            }
            .carousel-container { width: 100vw; max-width: 100vw; }
        }
        .carousel-images {
            position: relative;
            width: 100%;
            height: 100%;
        }
        .carousel-img {
            position: absolute;
            left: 0; top: 0;
            width: 100%; height: 100%;
            object-fit: cover;
            opacity: 0;
            transition: opacity 0.5s;
            z-index: 1;
        }
        .carousel-img.active {
            opacity: 1;
            z-index: 2;
        }
        .carousel-btn {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(90,62,200,0.7);
            color: #fff;
            border: none;
            border-radius: 50%;
            width: 36px; height: 36px;
            font-size: 22px;
            cursor: pointer;
            z-index: 10;
            outline: none;
        }
        .carousel-btn.prev { left: 12px; }
        .carousel-btn.next { right: 12px; }
        .carousel-dots {
            position: absolute;
            bottom: 16px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 10px;
            z-index: 10;
        }
        .carousel-dots span {
            display: block;
            width: 12px; height: 12px;
            border-radius: 50%;
            background: #ddd;
            cursor: pointer;
            transition: background 0.2s;
        }
        .carousel-dots .active {
            background: #5a3ec8;
        }
        @media (max-width: 900px) {
            .carousel-container { max-width: 100vw; border-radius: 0; }
            .carousel-btn.prev { left: 4px; }
            .carousel-btn.next { right: 4px; }
            .carousel-dots { bottom: 6px; }
        }
        .hotel-review-list {
            display: flex;
            flex-wrap: wrap;
            gap: 36px 4%;
            justify-content: flex-start;
        }
        .review-card {
            background: #faf8ff;
            border-radius: 16px;
            box-shadow: 0 2px 12px #e0d7f7;
            padding: 28px 32px;
            min-width: 320px;
            max-width: 420px;
            flex: 1 1 320px;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
        }
        .review-user {
            font-weight: 700;
            color: #5a3ec8;
            font-size: 18px;
            margin-bottom: 10px;
        }
        .review-content {
            color: #444;
            font-size: 17px;
            margin-bottom: 10px;
            line-height: 1.7;
        }
        .review-rating {
            color: #f5576c;
            font-size: 18px;
            font-weight: bold;
            margin-top: 4px;
        }
        .carousel-outer-container {
            max-width: 1100px;
            margin: 0 auto 36px auto;
            border-radius: 22px;
            box-shadow: 0 6px 32px #b3a6e6;
            padding: 40px 48px;
            display: flex;
            justify-content: center;
            background: transparent;
        }
        .carousel-container {
            width: 100%;
            max-width: 900px;
            aspect-ratio: 16/7;
            overflow: hidden;
            border-radius: 22px;
            box-shadow: 0 4px 24px rgba(0,0,0,0.12);
            margin: 0 auto;
            background: transparent;
            padding: 0;
            height: auto;
            display: flex;
        }
        .carousel-images {
            position: relative;
            width: 100%;
            height: 100%;
        }
        .carousel-img {
            position: absolute;
            left: 0; top: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 22px;
            margin: 0;
            display: block;
        }
        .hotel-info-container {
            max-width: 1100px;
            margin: 36px auto 0 auto;
            background: #fff;
            border-radius: 22px;
            box-shadow: 0 6px 32px #b3a6e6;
            padding: 40px 48px;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }
        .hotel-name {
            font-size: 32px;
            font-weight: 800;
            color: #5a3ec8;
            margin-bottom: 16px;
            letter-spacing: 1px;
        }
        .hotel-desc {
            color: #555;
            font-size: 20px;
            line-height: 1.8;
            font-weight: 400;
        }
        .top-carousel {
            max-width: 1100px;
            width: 100%;
            margin: 0 auto 48px auto;
            aspect-ratio: 16/7;
            overflow: hidden;
            position: relative;
            background: transparent;
            box-shadow: none;
            padding: 0;
            border-radius: 22px;
        }
        .carousel-images {
            position: relative;
            width: 100%;
            height: 100%;
        }
        .carousel-img {
            position: absolute;
            left: 0; top: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            border-radius: 22px;
            margin: 0;
            display: block;
        }
        .carousel-btn {
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: rgba(90,62,200,0.7);
            color: #fff;
            border: none;
            border-radius: 50%;
            width: 36px; height: 36px;
            font-size: 22px;
            cursor: pointer;
            z-index: 10;
            outline: none;
        }
        .carousel-btn.prev { left: 24px; }
        .carousel-btn.next { right: 24px; }
        .carousel-dots {
            position: absolute;
            bottom: 16px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 10px;
            z-index: 10;
        }
        .carousel-dots span {
            display: block;
            width: 12px; height: 12px;
            border-radius: 50%;
            background: #ddd;
            cursor: pointer;
            transition: background 0.2s;
        }
        .carousel-dots .active {
            background: #5a3ec8;
        }
    </style>
</head>
<body>
    <a href="index.html" class="back-home-btn">返回首页</a>
    <h1 class="main-title">酒店详情</h1>
    <!-- 轮播图片直接在页面顶部 -->
    <div class="top-carousel">
        <div class="carousel-images">
            <img src="img/double1.jpg" class="carousel-img active">
            <img src="img/family1.jpg" class="carousel-img">
            <img src="img/luxury1.jpg" class="carousel-img">
        </div>
        <button class="carousel-btn prev">&lt;</button>
        <button class="carousel-btn next">&gt;</button>
        <div class="carousel-dots"></div>
    </div>
    <!-- 酒店简介容器 -->
    <div class="hotel-info-container">
        <div class="hotel-name">大酒店</div>
        <div class="hotel-desc">这里是酒店简介，可展示星级、地理位置、特色等。</div>
    </div>
    <!-- 酒店房型区 -->
    <div class="section-container">
        <div class="section-title">酒店房型</div>
        <div class="room-type-list" id="roomTypeList"></div>
    </div>
    <!-- 酒店评价区 -->
    <div class="section-container">
        <div class="section-title">酒店评价</div>
        <div class="hotel-review-list" id="hotelReviewList"></div>
    </div>
    <div class="main-content">
    <div class="room-type-list" id="roomTypeList"></div>
    </div>
    <script>
        $(function() {
            $.ajax({
                url: 'http://localhost:8080/api/roomtype/list',
                type: 'GET',
                success: function(data) {
                    if (Array.isArray(data)) {
                        let html = '';
                        data.forEach(function(rt, idx) {
                            html += `
                                <div class="room-type-card" data-index="${idx}">
                                    ${rt.image1 ? `<img src="${rt.image1}" alt="房型图片">` : ''}
                                    <div class="room-type-info">
                                    <div class="room-type-title">${rt.typeName}</div>
                                    <div class="room-type-desc">${rt.description || ''}</div>
                                        <div class="info-line">床型：${rt.bedType}，床数：${rt.bedCount}</div>
                                        <div class="info-line">面积：${rt.areaSize}，楼层：${rt.floorInfo}</div>
                                    <div class="room-type-price">￥${rt.pricePerNight} / 晚</div>
                                    </div>
                                    <button class="room-type-book" onclick="event.stopPropagation();window.location.href='order.html?typeId=${rt.typeId}'">预订</button>
                                </div>
                            `;
                        });
                        $('#roomTypeList').html(html);

                        // 整个卡片可点击，后续可跳转详情
                        $('.room-type-card').on('click', function() {
                            var typeId = data[$(this).data('index')].typeId;
                            window.location.href = 'room-detail.html?typeId=' + typeId;
                        });
                    } else {
                        $('#roomTypeList').html('<div>暂无房型信息</div>');
                    }
                },
                error: function() {
                    $('#roomTypeList').html('<div>获取房型失败</div>');
                }
            });
        });
    </script>
    <script>
    // 酒店顶部轮播
    $(function(){
        var $imgs = $('.carousel-img');
        var $dots = $('.carousel-dots');
        var idx = 0, total = $imgs.length;
        $dots.html('');
        for(let i=0; i<total; i++){
            $dots.append('<span data-idx="'+i+'"></span>');
        }
        $dots.find('span').eq(0).addClass('active');
        function show(idxNew){
            $imgs.removeClass('active').eq(idxNew).addClass('active');
            $dots.find('span').removeClass('active').eq(idxNew).addClass('active');
            idx = idxNew;
        }
        var timer = null;
        function startTimer() {
            if(timer) clearInterval(timer);
            timer = setInterval(function(){ $('.carousel-btn.next').click(); }, 2000); // 2秒
        }
        $('.carousel-btn.prev').click(function(){
            show((idx-1+total)%total);
            startTimer();
        });
        $('.carousel-btn.next').click(function(){
            show((idx+1)%total);
            startTimer();
        });
        $dots.on('click','span',function(){
            show($(this).data('idx'));
            startTimer();
        });
        // 自动轮播
        startTimer();
        $('.top-carousel').hover(
            function(){ if(timer) clearInterval(timer); },
            function(){ startTimer(); }
        );
    });
    </script>
    <script>
    // 加载酒店评价及追评
    $.ajax({
        url: 'http://localhost:8080/api/hotel/reviews',
        type: 'GET',
        success: function(data) {
            let html = '';
            if(Array.isArray(data)) {
                let reviewCount = data.length;
                let loaded = 0;
                data.forEach(function(r) {
                    let cardId = 'appends_' + (r.orderId || r.reviewId || Math.random());
                    html += `
                        <div class="review-card">
                            <div class="review-user">${r.username || '匿名用户'}</div>
                            <div class="review-content">${r.reviewText}</div>
                            <div class="review-rating">评分：${r.rating || '无'}</div>
                            <div class="review-appends" id="${cardId}"></div>
                        </div>
                    `;
                });
                $('#hotelReviewList').html(html);
                // 逐条查追评
                data.forEach(function(r) {
                    let cardId = 'appends_' + (r.orderId || r.reviewId || Math.random());
                    $.get('http://localhost:8080/api/order/appendReview/list', {orderId: r.orderId}, function(appends) {
                        if(appends && appends.length > 0) {
                            let appendHtml = '<div class="append-title">追评：</div>';
                            appends.forEach(function(a) {
                                appendHtml += `<div class="append-item">${a.appendText} <span class="append-time">${a.appendTime ? a.appendTime.replace('T',' ').substring(0,16) : ''}</span></div>`;
                            });
                            $('#' + cardId).html(appendHtml);
                        }
                    });
                });
            } else {
                $('#hotelReviewList').html('<div>暂无评价</div>');
            }
        },
        error: function() {
            $('#hotelReviewList').html('<div>暂无评价</div>');
        }
    });
    </script>
    <style>
    .review-appends { margin-top: 10px; }
    .append-title { color: #5a3ec8; font-weight: bold; margin-bottom: 4px; }
    .append-item { background: #f7f3ff; border-radius: 8px; padding: 6px 10px; margin-bottom: 4px; font-size: 14px; }
    .append-time { color: #aaa; font-size: 12px; margin-left: 8px; }
    </style>
</body>
</html> 